<template>
  <div class="container">
    <div class="screen" ref="screen">
      <div class="top">
        <Top></Top>
      </div>
      <div class="bottom">
        <div class="left">
          <Bartotal class="bartotal"></Bartotal>
          <Barlevel class="barlevel"></Barlevel>
          <Barpart class="barpart"></Barpart>
        </div>
        <div class="center">
          <Map class="map"></Map>
          <Table class="table"></Table>
        </div>
        <div class="right">
          <Cloudpro class="cloudpro"></Cloudpro>
          <Cloudunit class="cloudunit"></Cloudunit>
          <Pie class="pie"></Pie>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import Top from './components/top.vue'
import Map from './components/map.vue'
import Cloudpro from './components/cloud_pro.vue'
import Cloudunit from './components/cloud_unit.vue'
import Bartotal from './components/bar_total.vue'
import Barlevel from './components/bar_level.vue'
import Barpart from './components/bar_participate.vue'
import Table from './components/table.vue'
import Pie from './components/pie.vue'

//获取数据大屏展示内容盒子的DOM元素
let screen = ref()
onMounted(() => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
})
//定义大屏缩放比例
function getScale(w = 1920, h = 1000) {
  const ww = window.innerWidth / w
  const wh = window.innerHeight / h
  return ww < wh ? ww : wh
}
//监听视口变化
window.onresize = () => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
}
</script>

<style scoped lang="scss">
.container {
  width: 100vw;
  height: 100vh;
  background-image: url('./assets/back.png');
  background-size: cover;
  color: white;

  .screen {
    position: fixed;
    width: 1920px;
    height: 1000px;
    left: 50%;
    top: 50%;
    transform-origin: left top;

    .top {
      width: 100%;
      height: 40px;
    }

    .bottom {
      display: flex;
      height: 960px;

      .left {
        flex: 1;
        display: flex;
        flex-direction: column;
        .bartotal {
          flex: 1;
        }

        .barlevel {
          flex: 1;
        }

        .barpart {
          flex: 1;
        }
      }
      .center {
        flex: 1.7;
        display: flex;
        flex-direction: column;

        .map {
          flex: 2;
        }

        .table {
          flex: 1;
        }
      }
      .right {
        flex: 1;
        display: flex;
        flex-direction: column;
        .cloudpro {
          flex: 1;
        }
        .cloudunit {
          flex: 1;
        }
        .pie {
          flex: 1;
        }
      }
    }
  }
}
</style>
